<?php //strip
/**
 * Administration table implementation for a single member.
 * 
 * @package odReservationsWpPlugin
 * @subpackage odReservationsWpPlugin_Tables
 * @author Ondrej Donek <ondrejd@gmail.com>
 */
class odReservationsWpPlugin_Tables_Member extends odWpPlugin_Admin_Table
{
	public function __construct()
	{
		$adminUrl = get_bloginfo('home') . '/wp-admin/admin.php';
		$model = new odReservationsWpPlugin_Models_Member();
		
		parent::__construct(array(
			'formUrl' => $adminUrl . '?page=' . odReservationsWpPlugin::ID . '-members',
			'editUrl' => $adminUrl . '?page=' . odReservationsWpPlugin::ID . '-add_member',
      'useModel' => true,
			'model' => $model,
			'columns' => array(
				'ID' => array(
					'primary' => true,
					'label' => __(' ', odReservationsWpPlugin::TEXTDOMAIN),
					'valueCol' => 'ID'
				),
				'fullname' => array(
					'label' => __('Příjmení, křestní jméno', odReservationsWpPlugin::TEXTDOMAIN),
					'valueCol' => 'fullname',
					'control' => true
				),
				'email' => array(
					'label' => __('Emailová adresa', odReservationsWpPlugin::TEXTDOMAIN),
					'valueCol' => 'email'
				),
				
				'credits_ordered' => array(
					'label' => __('Kredity - objednáno', odReservationsWpPlugin::TEXTDOMAIN),
					'valueCol' => 'credits_ordered'
				),
				'credits_left' => array(
					'label' => __('Kredity - zbývá', odReservationsWpPlugin::TEXTDOMAIN),
					'valueCol' => 'credits_left'
				)
			),
			'bulkActions' => false,
			'filters' => false,
			'maxrows' => 10,
			'primaryCol' => 'ID',
			'tree' => false,
			'editLink' => true,
			'editLinkCol' => 'fullname'
		));
	}
	
	protected function getItemsCount($aFilter = '1')
	{
		return $this->mModel->getCount('`t1`.`deleted` = 0');
	}
	
	protected function getItems($aFilter = '1', $aPerPage = 10, $aLimitFrom = 0)
	{
		return($this->mModel->select('`t1`.`deleted` = 0 ', $aPerPage, $aLimitFrom));
	}
} // End of odReservationsWpPlugin_Tables_Member
